{
	"translatorID": "874d70a0-6b95-4391-a681-c56dabaa1411",
	"translatorType": 4,
	"label": "clinicaltrials.gov",
	"creator": "Ryan Velazquez and contributors",
	"target": "^https://(classic\\.clinicaltrials\\.gov/ct2/(show|results)|(www\\.)?clinicaltrials\\.gov/(study|search))\\b",
	"minVersion": "5.0",
	"maxVersion": null,
	"priority": 100,
	"inRepository": true,
	"browserSupport": "gcsibv",
	"lastUpdated": "2025-01-15 17:45:00"
}

/*
	***** BEGIN LICENSE BLOCK *****

	Copyright © 2020 Ryan Velazquez and contributors

	This file is part of Zotero.

	Zotero is free software: you can redistribute it and/or modify
	it under the terms of the GNU Affero General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Zotero is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with Zotero. If not, see <http://www.gnu.org/licenses/>.

	***** END LICENSE BLOCK *****
*/


function detectWeb(doc, url) {
	let urlObject = new URL(url);

	if (urlObject.pathname === "/search") {
		// Watch for disappearance/appearance of results due to filtering
		let resultsNode = doc.querySelector(".results-content-area");
		if (resultsNode) {
			// after the node has been generated by ajax, watch it
			Zotero.monitorDOMChanges(resultsNode);
		}

		if (getSearchResults(doc, true/* checkOnly */)) {
			return "multiple";
		}
	}
	else if (urlObject.pathname.startsWith("/study/")) {
		return "report";
	}
	return false;
}

// The keys in the returned item will be the NCTId, which is enough for
// identifying a report
function getSearchResults(doc, checkOnly) {
	var items = {};
	var found = false;
	var rows = doc.querySelectorAll("ctg-search-hit-card header > a[href^='/study/']");
	for (let row of rows) {
		let id = getClinicalTrialID(row.href);
		let title = ZU.trimInternal(row.textContent);
		if (!id || !title) continue;
		if (checkOnly) return true;
		found = true;
		items[id] = title;
	}
	return found ? items : false;
}

async function doWeb(doc, url) {
	if (detectWeb(doc, url) == "multiple") {
		let trialIDs = await Z.selectItems(getSearchResults(doc));
		if (!trialIDs) return;
		for (let id of Object.keys(trialIDs)) {
			await scrape(id);
		}
	}
	else {
		await scrape(getClinicalTrialID(url));
	}
}

async function scrape(clinicalTrialID) {
	let jsonRequestURL = `https://clinicaltrials.gov/api/int/studies/${clinicalTrialID}`;
	studiesJSONToItem(await requestJSON(jsonRequestURL));
}

function getClinicalTrialID(url) {
	let pathComponents = new URL(url).pathname.split("/");
	return pathComponents[pathComponents.length - 1]; // last component in pathname
}

function studiesJSONToItem(data) {
	let item = new Zotero.Item("report");

	let study = data.study;

	// Start get the creator info
	let creators = [];

	let authorModule = study.protocolSection.sponsorCollaboratorsModule;
	let firstAuthor = authorModule.responsibleParty;
	let leadSponsor = authorModule.leadSponsor;

	let investigatorName;
	if (firstAuthor && firstAuthor.type !== "SPONSOR") { // a person
		// Clean up the comma trailing titles such as "First Last, MD, PhD"
		investigatorName = firstAuthor.investigatorFullName || firstAuthor.oldNameTitle;
		let cleanName = investigatorName.split(", ")[0];
		creators.push(ZU.cleanAuthor(cleanName, "author"));
	}

	if (leadSponsor && leadSponsor.name !== investigatorName) {
		// lead sponsor is not a duplicate of the PI
		creators.push({
			lastName: leadSponsor.name,
			creatorType: (creators.length ? "contributor" : "author"),
			fieldMode: 1
		});
	}

	if (authorModule.collaborators) {
		for (let entity of authorModule.collaborators) {
			if (entity && entity.name) {
				creators.push({
					lastName: entity.name,
					creatorType: "contributor",
					fieldMode: 1
				});
			}
		}
	}

	item.creators = creators;

	let idModule = study.protocolSection.identificationModule;
	let statusModule = study.protocolSection.statusModule;

	item.title = idModule.officialTitle;
	item.date = statusModule.lastUpdateSubmitDate;
	item.institution = "clinicaltrials.gov"; // publisher
	item.reportNumber = idModule.nctId;
	item.shortTitle = idModule.briefTitle;
	item.abstractNote = ZU.cleanTags(study.protocolSection.descriptionModule.briefSummary);
	item.url = "https://clinicaltrials.gov/study/" + idModule.nctId;
	item.reportType = "Clinical trial registration";
	item.extra = `submitted: ${statusModule.studyFirstSubmitDate}`;
	item.complete();
}

/** BEGIN TEST CASES **/
var testCases = [
	{
		"type": "web",
		"url": "https://clinicaltrials.gov/study/NCT04292899",
		"items": [
			{
				"itemType": "report",
				"title": "A Phase 3 Randomized Study to Evaluate the Safety and Antiviral Activity of Remdesivir (GS-5734™) in Participants With Severe COVID-19",
				"creators": [
					{
						"lastName": "Gilead Sciences",
						"creatorType": "author",
						"fieldMode": 1
					}
				],
				"date": "2020-12-15",
				"abstractNote": "The primary objective of this study is to evaluate the efficacy of 2 remdesivir (RDV) regimens with respect to clinical status assessed by a 7-point ordinal scale on Day 14.",
				"extra": "submitted: 2020-02-28",
				"institution": "clinicaltrials.gov",
				"libraryCatalog": "clinicaltrials.gov",
				"reportNumber": "NCT04292899",
				"reportType": "Clinical trial registration",
				"shortTitle": "Study to Evaluate the Safety and Antiviral Activity of Remdesivir (GS-5734™) in Participants With Severe Coronavirus Disease (COVID-19)",
				"url": "https://clinicaltrials.gov/study/NCT04292899",
				"attachments": [],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://clinicaltrials.gov/study/NCT00287391",
		"items": [
			{
				"itemType": "report",
				"title": "The Impact of Gastroesophageal Reflux Disease in Sleep Disorders: A Pilot Investigation of Rabeprazole, 20 mg Twice Daily for the Relief of GERD-Related Insomnia.",
				"creators": [
					{
						"lastName": "University of North Carolina",
						"creatorType": "author",
						"fieldMode": 1
					},
					{
						"lastName": "Janssen Pharmaceutica N.V., Belgium",
						"creatorType": "contributor",
						"fieldMode": 1
					}
				],
				"date": "2007-04-25",
				"abstractNote": "This study will investigate Gastroesophageal Reflux Disease (GERD)as a cause of sleep disturbance.\nPatients with GERD may experience all or some of the following symptoms: stomach acid or partially digested food re-entering the esophagus (which is sometimes referred to as heartburn or regurgitation) and belching.\nEven very small, unnoticeable amounts of rising stomach acid may cause patients to wake up during the night.\n\nThis study will also investigate the effect of Rabeprazole, (brand name Aciphex) on patients with known insomnia.\nRabeprazole is an FDA approved medication already marketed for the treatment of GERD.",
				"extra": "submitted: 2006-02-03",
				"institution": "clinicaltrials.gov",
				"libraryCatalog": "clinicaltrials.gov",
				"reportNumber": "NCT00287391",
				"reportType": "Clinical trial registration",
				"shortTitle": "Sleep Disorders and Gastroesophageal Reflux Disease (GERD)",
				"url": "https://clinicaltrials.gov/study/NCT00287391",
				"attachments": [],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://clinicaltrials.gov/study/NCT04261517?recrs=e&cond=COVID&draw=2",
		"items": [
			{
				"itemType": "report",
				"title": "Efficacy and Safety of Hydroxychloroquine for Treatment of COVID-19",
				"creators": [
					{
						"firstName": "Hongzhou",
						"lastName": "Lu",
						"creatorType": "author"
					},
					{
						"lastName": "Shanghai Public Health Clinical Center",
						"creatorType": "contributor",
						"fieldMode": 1
					}
				],
				"date": "2020-04-09",
				"abstractNote": "The study aims to evaluate the efficacy and safety of hydroxychloroquine in the treatment of COVID-19 pneumonia.",
				"extra": "submitted: 2020-02-06",
				"institution": "clinicaltrials.gov",
				"libraryCatalog": "clinicaltrials.gov",
				"reportNumber": "NCT04261517",
				"reportType": "Clinical trial registration",
				"url": "https://clinicaltrials.gov/study/NCT04261517",
				"attachments": [],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://clinicaltrials.gov/study/NCT04292899",
		"items": [
			{
				"itemType": "report",
				"title": "A Phase 3 Randomized Study to Evaluate the Safety and Antiviral Activity of Remdesivir (GS-5734™) in Participants With Severe COVID-19",
				"creators": [
					{
						"lastName": "Gilead Sciences",
						"creatorType": "author",
						"fieldMode": 1
					}
				],
				"date": "2020-12-15",
				"abstractNote": "The primary objective of this study is to evaluate the efficacy of 2 remdesivir (RDV) regimens with respect to clinical status assessed by a 7-point ordinal scale on Day 14.",
				"extra": "submitted: 2020-02-28",
				"institution": "clinicaltrials.gov",
				"libraryCatalog": "clinicaltrials.gov",
				"reportNumber": "NCT04292899",
				"reportType": "Clinical trial registration",
				"shortTitle": "Study to Evaluate the Safety and Antiviral Activity of Remdesivir (GS-5734™) in Participants With Severe Coronavirus Disease (COVID-19)",
				"url": "https://clinicaltrials.gov/study/NCT04292899",
				"attachments": [],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://www.clinicaltrials.gov/search?term=transgender%20care",
		"defer": true,
		"items": "multiple"
	},
	{
		"type": "web",
		"url": "https://clinicaltrials.gov/study/NCT01159457",
		"items": [
			{
				"itemType": "report",
				"title": "Engerix B Versus Sci-B-Vac Immunization in a Celiac Population of Non-responders to Primary Hepatitis B Immunization Series - a Randomized Controlled Trial",
				"creators": [
					{
						"firstName": "Lena",
						"lastName": "Rachman",
						"creatorType": "author"
					},
					{
						"lastName": "Shaare Zedek Medical Center",
						"creatorType": "contributor",
						"fieldMode": 1
					}
				],
				"date": "2011-04-14",
				"abstractNote": "Celiac disease and infection with hepatitis B virus (HBV) are very prevalent worldwide and carry a high morbidity rate.\nIt has been recently shown that patients with celiac disease very often fail to develop immunity after standard vaccination for HBV during infancy.\nIn this study, we will evaluate whether a second vaccination series with a different vaccine, Sci-B-Vac, results in a better immunological response in celiac patients.\nEligible patients will be randomized to receive a 3-dose vaccination series with Engerix or Sci-B-Vac vaccines.. Rate of responders and level of immunity will be compared.\nThis study will facilitate better protection of celiac patients to this potentially deadly virus.",
				"extra": "submitted: 2010-07-08",
				"institution": "clinicaltrials.gov",
				"libraryCatalog": "clinicaltrials.gov",
				"reportNumber": "NCT01159457",
				"reportType": "Clinical trial registration",
				"shortTitle": "Comparison of Engerix B Vaccine Versus Sci-B-Vac Vaccine in Celiac Patients",
				"url": "https://clinicaltrials.gov/study/NCT01159457",
				"attachments": [],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	}
]
/** END TEST CASES **/
